<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>pyftpdlib Frequently Asked Questions</title>
</head>

<body>
<h1>pyftpdlib Frequently Asked Questions</h1>
<h1>1.0 - Introduction</h1>
<h3>1.1 - What is pyftpdlib?</h3>
<p>pyftpdlib is a high-level library to easily write asynchronous portable FTP servers with <a href="http://www.python.org/" rel="nofollow">Python</a>. </p>
<h3>1.2 - What is Python?</h3>
<p>Python is an interpreted, interactive, object-oriented, easy-to-learn programming language. It is often compared to <em>Tcl, Perl, Scheme</em> or <em>Java</em>. </p>
<h3>1.3 - I'm not a python programmer. Can I use it anyway?</h3>
<p>Yes. pyftpdlib is a fully working FTP server implementation that can be run &quot;as is&quot;. For example, (after having installed a <a href="http://www.python.org/download/" rel="nofollow">Python interpreter</a>) you could run an anonymous ftp server from cmd-line by running: </p>
<pre>python -m pyftpdlib.FTPServer</pre>
<p>Customizing  ftpd more deeply requires a python script which imports pyftpdlib to be  written separately. Customizing ftpd for basic tasks like adding users  or deciding where log file should be placed is mostly simply editing  variables. This is basically like learning how to edit a common unix  ftpd.conf file and doesn't really require Python knowledge. </p>
<h3>1.4 - Documentation</h3>
<p><a href="http://code.google.com/p/pyftpdlib/" rel="nofollow">http://code.google.com/p/pyftpdlib/</a> is the primary source for all information about the project including <a href="http://code.google.com/p/pyftpdlib/wiki/Tutorial" rel="nofollow">Tutorial</a>, <a href="http://code.google.com/p/pyftpdlib/w/list" rel="nofollow">Wikis</a> and the <a href="http://code.google.com/p/pyftpdlib/issues/list" rel="nofollow">Bug Tracker</a>. </p>
<h3>1.5 - Mailing lists</h3>
<p>There are a number of mailing lists for pyftpdlib: </p>
<table border="1" cellpadding="1" cellspacing="1">
  <tbody>
    <tr>
      <td><strong>Name</strong> </td>
      <td><strong>E-mail</strong> </td>
      <td><strong>Web Interface</strong> </td>
      <td><strong>Description</strong> </td>
    </tr>
    <tr>
      <td><a href="http://groups.google.com/group/pyftpdlib" rel="nofollow">pyftpdlib-users</a> </td>
      <td> pyftpdlib@googlegroups.com </td>
      <td><a href="http://groups.google.com/group/pyftpdlib/topics" rel="nofollow">topics</a> </td>
      <td> This is intended for end user support. </td>
    </tr>
    <tr>
      <td><a href="http://groups.google.com/group/pyftpdlib-commit" rel="nofollow">pyftpdlib-commit</a> </td>
      <td> pyftpdlib-commits@googlegroups.com </td>
      <td><a href="http://groups.google.com/group/pyftpdlib-commit/topics" rel="nofollow">topics</a> </td>
      <td> This list receives all change notifications for code in the Subversion  repository. Unless you're a pyftpdlib developer you will probably not  be interested in it. </td>
    </tr>
    <tr>
      <td><a href="http://groups.google.com/group/pyftpdlib-issues" rel="nofollow">pyftpdlib-issues</a> </td>
      <td> pyftpdlib-issues@googlegroups.com </td>
      <td><a href="http://groups.google.com/group/pyftpdlib-issues/topics" rel="nofollow">topics</a> </td>
      <td> This list receives all change notifications from the <a href="http://code.google.com/p/pyftpdlib/issues/list" rel="nofollow">Bug Tracker</a>. Unless you are involved into pyftpdlib development you will probably not find this useful. </td>
    </tr>
  </tbody>
</table>
<h1></h1>
<h3>1.6 - Bug reporting</h3>
<p>Bug reports should be made via Google Code <a href="http://code.google.com/p/pyftpdlib/issues/list" rel="nofollow">Issue Tracker</a>. Patches should be attached to the appropriate bug and not mailed directly to the mailing lists or any given team member. </p>
<h1>2.0 - Installing and compatibility</h1>
<h3>2.1 - How do I install pyftpdlib?</h3>
<p>First download latest package release release from the <a href="http://code.google.com/p/pyftpdlib/downloads/list" rel="nofollow">Download Page</a>, then unpack it into a directory (on unix: <em>tar -zxf pyftpdlib_0.x.x.tar.gz</em>) and run: </p>
<pre>python setup.py install</pre>
<p>If you're on Windows it should be enough just running: </p>
<pre>setup.py install</pre>
<h3>2.2 - Which Python versions are compatible?</h3>
<p><a href="http://www.python.org/download/releases/2.3.6/" rel="nofollow">Python 2.3</a> and higher. </p>
<h3>2.3 - Which one is recommended?</h3>
<p><strong>Python 2.4</strong> or <strong>2.5</strong> because of the newer collection.deque object which provides better performances for file transfers. </p>
<h3>2.4 - On which platforms can pyftpdlib be used?</h3>
<p>pyftpdlib should work on any platform where <em>select( )</em> or <em>poll( )</em> are available. The development team has mainly tested it under various <strong>Linux</strong> and <strong>Windows</strong> systems and <strong>OS X</strong>. A <strong><a href="http://www.freshports.org/ftp/py-pyftpdlib/" rel="nofollow">port for FreeBSD</a></strong> systems is also available and maintained by Li-Wen Hsu &lt;lwhsu@freebsd.org&gt;. </p>
<h1>3.0 - Usage</h1>
<h3>3.1 - Why do I get socket.error &quot;Permission denied&quot; error on ftpd starting?</h3>
<p>Probably because you're on a unix system and you're trying to start ftpd as an unprivileged user. <em>ftpserver.py</em> binds on port 21 by default and only super-user account (e.g. root)  could bind sockets on such ports. If you want to bind ftpd as  non-privileged user you should set a port higher than 1024. </p>
<h3>3.2 - How can I prevent the server version from being displayed?</h3>
<p>Just override and modify banner attribute of FTPHandler class. </p>
<h3>3.3 - Can control upload/download ratios?</h3>
<p>Yes. There's an example of a hack around asyncore socket_map in the <a href="http://code.google.com/p/pyftpdlib/wiki/Tutorial" rel="nofollow">Tutorial</a> wiki. </p>
<h3>3.4 - Are there ways to limit connections?</h3>
<p>FTPServer class comes with two overridable attributes defaulting to zero (no limit): max_cons, which sets a limit for maximum simultaneous connection to handle by ftpd and max_cons_per_ip  which set a limit for connections from the same IP address. Overriding  these variables is always recommended to avoid DoS attacks. </p>
<h3>3.5 - I'm behind a NAT / gateway</h3>
<p>When  behind a NAT a ftp server needs to replace the IP local address  displayed in PASV replies and instead use the public address of the NAT  to allow client to connect. By overriding masquerade_address attribute of FTPHandler  class you will force pyftpdlib to do such replacement. However, one big  problem still exists. The passive FTP connections will use ports from  1024 and up, which means that you must forward all ports 1024-65535  from the NAT to the FTP server! And you have to allow many (possibly)  dangerous ports in your firewalling rules! To resolve this, simply  override passive_ports attribute of FTPHandler class to control what ports proftpd will use for its passive data transfers.  Value expected by passive_ports  attribute is a list of integers (e.g. range(60000, 65535)) indicating  which ports will be used for initializing the passive data channel. </p>
<h3>3.6.1 - What is FXP?</h3>
<p>FXP is part of the name of a popular Windows FTP client: <a href="http://www.flashfxp.com" rel="nofollow">http://www.flashfxp.com</a>.  This client has made the name &quot;FXP&quot; commonly used as a synonym for  site-to-site FTP transfers, for transferring a file between two remote  FTP servers without the transfer going through the client's host.  Sometimes &quot;FXP&quot; is referred to as a protocol; in fact, it is not. The  site-to-site transfer capability was deliberately designed into <a href="http://www.faqs.org/rfcs/rfc959.html" rel="nofollow">RFC 959</a>. More info can be found here: <a href="http://www.proftpd.org/docs/howto/FXP.html" rel="nofollow">http://www.proftpd.org/docs/howto/FXP.html</a>. </p>
<h3>3.6.2 - Does pyftpdlib support FXP?</h3>
<p>Yes. It is disabled by default for security reasons (see <a href="http://gim.org.pl/rfcs/rfc2577.html" rel="nofollow">RFC 2257</a> and <a href="http://www.cert.org/advisories/CA-1997-27.html" rel="nofollow">FTP bounce attack description</a>) but in case you want to enable it just set to True the permit_foreign_addresses attribute of FTPHandler class. </p>
<h1>4.0 - Implementation</h1>
<h3>4.1 - Globbing / STAT command implementation</h3>
<p>Globbing  is a common Unix shell mechanism for expanding wildcard patterns to  match multiple filenames. When an argument is provided to the <strong>STAT</strong> command, ftpd should return directory listing over the command channel. <a href="http://www.faqs.org/rfcs/rfc959.html" rel="nofollow">RFC 959</a> does not explicitly mention globbing; this means that FTP servers are  not required to support globbing in order to be compliant. However,  many FTP servers (including pyftpdlib) <em>do</em> support globbing as a  measure of convenience for FTP clients and users. In order to search  for and match the given globbing expression, the code has to search  (possibly) many directories, examine each contained filename, and build  a list of matching files in memory. Since this operation can be quite  intensive, both CPU- and memory-wise, pyftpdlib limits the search to  only one directory non-recursively, which is identical to the <strong>LIST</strong> command implementation in pyftpdlib. </p>
<h3>4.2 - ASCII transfers / SIZE command implementation</h3>
<p>Properly  handling the SIZE command when TYPE ASCII is used would require to scan  the entire file to perform the ASCII translation logic  (file.read().replace(os.linesep, '\r\n')) and then calculating the len  of such data which may be different than the actual size of the file on  the server. Considering that calculating such result could be very  resource-intensive it could be easy for a malicious client to try a DoS  attack, thus pyftpdlib do not perform the ASCII translation. However,  clients in general should not be resuming downloads in ASCII mode.  Resuming downloads in binary mode is the recommended way as specified  in <a href="http://www.faqs.org/rfcs/rfc3659.html" rel="nofollow">RFC 3659</a>. </p>
<h3>4.3 - IPv6 support</h3>
<p>IPv6 support for FTP including <em>EPRT &amp; EPSV</em> commands is a feature defined in <a href="http://www.faqs.org/rfcs/rfc2428.html" rel="nofollow">RFC 2428</a>. There is currently no official support for IPv6 within the 0.2.x code tree. </p>
<h3>4.4 - SSL/TLS support</h3>
<p>SSL/TLS support including <em>AUTH, ADAT, PROT, PBSZ, CCC, MIC, CONF</em> and <em>ENC</em> commands is a feature defined in <a href="http://www.faqs.org/rfcs/rfc2228.html" rel="nofollow">RFC 2228</a>.  There is currently no official support for SSL/TLS within the 0.2.x  code tree. Contributors willing to help add support for these protocols  are greatly appreciated. </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
